import kgRequest from '@/service'
import type {
  articleDisplay,
  cpInfo,
  selectFile,
  selectInfo,
  selectOtherInfo,
  uploadAvatar,
  uploadPublish
} from './type'

// 获取用户信息
export function selectInfoApi(data: selectInfo.IParms) {
  return kgRequest.post<selectInfo.IRes>({
    url: '/api/user/selectInfo',
    data
  })
}

// 修改资料
export function cpInfoApi(data: cpInfo.IParms) {
  return kgRequest.post<cpInfo.IRes>({
    url: '/api/user/cpInfo',
    data
  })
}

// 上传头像
export function uploadAvatarApi(data: uploadAvatar.TParms) {
  return kgRequest.post<uploadAvatar.IRes>({
    url: '/api/user/upload',
    headers: {
      ContentType: 'multipart/form-data'
    },
    data
  })
}

// 上传图片
export function uploadImageApi(data: uploadAvatar.TParms) {
  return kgRequest.post<uploadAvatar.IRes>({
    url: '/api/file/upImage',
    headers: {
      ContentType: 'multipart/form-data'
    },
    data
  })
}

// 获取用户文章列表
export function selectFileApi(data = {}) {
  return kgRequest.post<selectFile.IRes>({
    url: '/api/user/selectFile',
    data
  })
}

// 发布
export function uploadPublishApi(data: uploadPublish.IParms) {
  return kgRequest.post({
    url: '/api/file/upload',
    data
  })
}

// 查询固定标签
export function preSelectListApi(data = {}) {
  return kgRequest.post({
    url: '/api/file/preSelectList',
    data
  })
}

// 获取文章详情
export function articleDisplayApi(data: articleDisplay.IParms) {
  return kgRequest.post<articleDisplay.IRes>({
    url: '/api/file/display',
    data
  })
}

// 获取其他人的信息（包括用户信息、文章、模型等）
export function selectOtherInfoApi(data: selectOtherInfo.IParms) {
  return kgRequest.post<selectOtherInfo.IRes>({
    url: '/api/user/selectOtherInfo',
    data
  })
}
